package com.huatai.bpmn.commom.dto;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

/**
 * @author yxy
 */
@Data
public class PageDTO {
    public final static String PAGE_INDEX = "pgIndex";
    public final static String PAGE_SIZE = "pgSize";

    private int pgSize = 10;
    private int pgIndex = 0;

    public PageDTO pageParam(JSONObject data) {
        this.pgIndex = Integer.parseInt(data.getOrDefault(PAGE_INDEX, "1").toString());
        this.pgSize = Integer.parseInt(data.getOrDefault(PAGE_SIZE, "10").toString());

        return this;
    }

    public IPage buildPage(JSONObject data){
        this.pageParam(data);
        return new Page(pgIndex,pgSize);
    }

    public PageDTO PageDTO() {
        return this;
    }



}
